package evolution.problem;

import static java.lang.Math.pow;

public class Camelback2DMinimization extends AbstractMinimizationProblem {

	public static final Problem2DConstraints CONSTRAINTS = new Problem2DConstraints(
			-5, 5);

	public Camelback2DMinimization() {
		super(CONSTRAINTS);
	}

	/**
	 * http://www.math.ntu.edu.tw/~wwang/cola_lab/test_problems/multiple_opt/
	 * multiopt_prob/Camel3/camel3.htm
	 */
	@Override
	public double getValue(double[] x) {
		double x1 = x[0];
		double x2 = x[1];
		return 2 * x1 * x1 - 1.05 * pow(x1, 4) + pow(x1, 6) / 6 + x1 * x2 + x2
				* x2;
	}

	@Override
	public String getGnuplotFunction() {
		return "2*x**2 - 1.05*x**4 + x**6/6 + x*y + y**2";
	}

	@Override
	public String getGnuplotFunctionName() {
		return "camelback_3_hump";
	}
}
